package com.xhs.listener;

import com.mybatisflex.annotation.InsertListener;
import com.mybatisflex.annotation.UpdateListener;
import com.xhs.entity.BaseEntity;

/**
 * @desc: 数据填充监听器
 * @projectName: mybatis-flex-demo
 * @author: xhs
 * @date: 2024-07-18 018 15:27
 * @version: JDK 1.8
 */
public class EntityListener implements InsertListener, UpdateListener {

    /**
     * 新增数据
     *
     * @param entity 入参
     */
    @Override
    public void onInsert(Object entity) {
        BaseEntity baseEntity = (BaseEntity) entity;
        baseEntity.setCreateUser("superAdmin");
    }

    /**
     * 修改数据
     *
     * @param entity 入参
     */
    @Override
    public void onUpdate(Object entity) {
        BaseEntity baseEntity = (BaseEntity) entity;
        baseEntity.setCreateUser("bizAdmin");
    }
}
